package com.ylc.project.service.impl.inner;

import com.ylc.ylcapicommon.service.InnerNonceUtilService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.data.redis.core.RedisTemplate;

import javax.annotation.Resource;
import java.util.Set;

/**
 * @Author: ylc
 * @Description:
 */
@DubboService
public class InnerNonceUtilServiceImpl implements InnerNonceUtilService {

    @Resource
    private RedisTemplate redisTemplate;
    @Override
    public void setNonce(String nonce, String path) {
        redisTemplate.opsForSet().add(nonce, path);
    }

    @Override
    public boolean validNonce(String nonce) {
        Set<String> members = redisTemplate.opsForSet().members(nonce);
        return !members.isEmpty();
    }
}
